import { Animation, CSSAnimation } from "../core/animation";
import AppNode from "../core/app_node";
import { EleDiv } from "../core/data_ext";
import Progress from "../core/prefabs/progress";
import { RegClass } from "../core/serialize";
import Utils, { H5Utils, rAF } from "../core/utils";


@RegClass("PageUI")
export default class PageUI extends AppNode {
    dragContain: HTMLDivElement = null;
    dragItem: HTMLDivElement = null;
    ball: EleDiv = null;

    pb: Progress = null;
    async onLoad() {
        H5Utils.DragElement(this.dragItem, this.dragContain);
        let num = 0;
        rAF.set(() => {
            num += 1;
            if (num > 100) {
                num = 0;
            }
            this.pb.progress = num;
        }, 100);

        while (1) {
            let ani1 = new CSSAnimation(500, this.ball, {
                left: 50,
            }, {
                left: "px",
            });
            await ani1.play().await();
            let ani2 = new CSSAnimation(500, this.ball, {
                left: 250,
            }, {
                left: "px",
            });
            await ani2.play().await();
        }
    }
    onClickMsgBox() {
        Utils.app.msgBox("12312312123123123123123123123");
    }
    onClickMsgBoxYesNo() {
        Utils.app.msgBoxYesNo("12312312123123123123123123123");
    }

};